home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Music / PLAY / superplay-lib / SuperPlay / SuperPlay_Main.c < prev    next >
C/C++ Source or Header  |  1995-08-23  |  6KB  |  213 lines

  1. /*
  2.  *  Source machine generated by GadToolsBox V2.0b
  3.  *  which is (c) Copyright 1991-1993 Jaba Development
  4.  *
  5.  *  GUI Designed by : Andreas R. Kleinert
  6.  */
  7.  
  8. #include <exec/types.h>
  9. #include <intuition/intuition.h>
  10. #include <intuition/classes.h>
  11. #include <intuition/classusr.h>
  12. #include <intuition/imageclass.h>
  13. #include <intuition/gadgetclass.h>
  14. #include <libraries/gadtools.h>
  15. #include <graphics/displayinfo.h>
  16. #include <graphics/gfxbase.h>
  17. #include <clib/exec_protos.h>
  18. #include <clib/intuition_protos.h>
  19. #include <clib/gadtools_protos.h>
  20. #include <clib/graphics_protos.h>
  21. #include <clib/utility_protos.h>
  22. #include <string.h>
  23. #include "SuperPlay_Main.h"
  24.  
  25. struct Screen         *Scr = NULL;
  26. UBYTE                 *PubScreenName = "Workbench";
  27. APTR                   VisualInfo = NULL;
  28. struct Window         *SP_Main_Wnd = NULL;
  29. struct Gadget         *SP_Main_GList = NULL;
  30. struct Gadget         *SP_Main_Gadgets[9];
  31. UWORD                  SP_Main_Left = 0;
  32. UWORD                  SP_Main_Top = 11;
  33. UWORD                  SP_Main_Width = 522;
  34. UWORD                  SP_Main_Height = 52;
  35. UBYTE                 *SP_Main_Wdt = (UBYTE *)"SuperPlay V3.1, © 1994 by Andreas R. Kleinert";
  36. struct TextAttr       *Font, Attr;
  37. UWORD                  FontX, FontY;
  38. UWORD                  OffX, OffY;
  39.  
  40. extern struct MinList SPOGad0List;
  41.  
  42. struct Node SPOGad0Nodes[] = {
  43.     &SPOGad0Nodes[1], ( struct Node * )&SPOGad0List.mlh_Head, 0, 0, "8svx",
  44.     ( struct Node * )&SPOGad0List.mlh_Tail, &SPOGad0Nodes[0], 0, 0, "voc" };
  45.  
  46. struct MinList SPOGad0List = {
  47.     ( struct MinNode * )&SPOGad0Nodes[0], ( struct MinNode * )NULL, ( struct MinNode * )&SPOGad0Nodes[1] };
  48.  
  49. UWORD SP_Main_GTypes[] = {
  50.     BUTTON_KIND,
  51.     BUTTON_KIND,
  52.     BUTTON_KIND,
  53.     BUTTON_KIND,
  54.     BUTTON_KIND,
  55.     BUTTON_KIND,
  56.     BUTTON_KIND,
  57.     BUTTON_KIND,
  58.     LISTVIEW_KIND
  59. };
  60.  
  61. struct NewGadget SP_Main_NGad[] = {
  62.     99, 34, 210, 16, (UBYTE *)"Load and _Convert to :", NULL, GD_ConvertGad, PLACETEXT_IN, NULL, NULL,
  63.     3, 1, 122, 16, (UBYTE *)"Load and _Play", NULL, GD_PlayGad, PLACETEXT_IN, NULL, NULL,
  64.     3, 17, 57, 16, (UBYTE *)"_Stop", NULL, GD_StopGad, PLACETEXT_IN, NULL, NULL,
  65.     61, 17, 87, 16, (UBYTE *)"Con_tinue", NULL, GD_ContGad, PLACETEXT_IN, NULL, NULL,
  66.     149, 17, 76, 16, (UBYTE *)"_Forward", NULL, GD_ForGad, PLACETEXT_IN, NULL, NULL,
  67.     226, 17, 83, 16, (UBYTE *)"_Backward", NULL, GD_BackGad, PLACETEXT_IN, NULL, NULL,
  68.     125, 1, 184, 16, (UBYTE *)"Get File _Information", NULL, GD_InfoGad, PLACETEXT_IN, NULL, NULL,
  69.     3, 34, 95, 16, (UBYTE *)"_LED", NULL, GD_LEDGad, PLACETEXT_IN, NULL, NULL,
  70.     310, 1, 209, 56, NULL, NULL, GD_SPOGad, 0, NULL, NULL
  71. };
  72.  
  73. ULONG SP_Main_GTags[] = {
  74.     (GT_Underscore), '_', (TAG_DONE),
  75.     (GT_Underscore), '_', (TAG_DONE),
  76.     (GT_Underscore), '_', (TAG_DONE),
  77.     (GT_Underscore), '_', (TAG_DONE),
  78.     (GT_Underscore), '_', (TAG_DONE),
  79.     (GT_Underscore), '_', (TAG_DONE),
  80.     (GT_Underscore), '_', (TAG_DONE),
  81.     (GT_Underscore), '_', (TAG_DONE),
  82.     (GTLV_Labels), (ULONG)&SPOGad0List, (GTLV_ShowSelected), NULL, (LAYOUTA_Spacing), 1, (TAG_DONE)
  83. };
  84.  
  85. static UWORD ComputeX( UWORD value )
  86. {
  87.     return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
  88. }
  89.  
  90. static UWORD ComputeY( UWORD value )
  91. {
  92.     return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
  93. }
  94.  
  95. static void ComputeFont( UWORD width, UWORD height )
  96. {
  97.     Font = &Attr;
  98.     Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
  99.     Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
  100.     FontX = Scr->RastPort.Font->tf_XSize;
  101.  
  102.     OffX = Scr->WBorLeft;
  103.     OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
  104.  
  105.     if ( width && height ) {
  106.         if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
  107.             goto UseTopaz;
  108.         if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
  109.             goto UseTopaz;
  110.     }
  111.     return;
  112.  
  113. UseTopaz:
  114.     Font->ta_Name = (STRPTR)"topaz.font";
  115.     FontX = FontY = Font->ta_YSize = 8;
  116. }
  117.  
  118. int SetupScreen( void )
  119. {
  120.     if ( ! ( Scr = LockPubScreen( PubScreenName )))
  121.         return( 1L );
  122.  
  123.     ComputeFont( 0, 0 );
  124.  
  125.     if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
  126.         return( 2L );
  127.  
  128.     return( 0L );
  129. }
  130.  
  131. void CloseDownScreen( void )
  132. {
  133.     if ( VisualInfo ) {
  134.         FreeVisualInfo( VisualInfo );
  135.         VisualInfo = NULL;
  136.     }
  137.  
  138.     if ( Scr        ) {
  139.         UnlockPubScreen( NULL, Scr );
  140.         Scr = NULL;
  141.     }
  142. }
  143.  
  144. int OpenSP_Main_Window( void )
  145. {
  146.     struct NewGadget    ng;
  147.     struct Gadget    *g;
  148.     UWORD        lc, tc;
  149.     UWORD        wleft = SP_Main_Left, wtop = SP_Main_Top, ww, wh;
  150.  
  151.     ComputeFont( SP_Main_Width, SP_Main_Height );
  152.  
  153.     ww = ComputeX( SP_Main_Width );
  154.     wh = ComputeY( SP_Main_Height );
  155.  
  156.     if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
  157.     if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
  158.  
  159.     if ( ! ( g = CreateContext( &SP_Main_GList )))
  160.         return( 1L );
  161.  
  162.     for( lc = 0, tc = 0; lc < SP_Main__CNT; lc++ ) {
  163.  
  164.         CopyMem((char * )&SP_Main_NGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  165.  
  166.         ng.ng_VisualInfo = VisualInfo;
  167.         ng.ng_TextAttr   = Font;
  168.         ng.ng_LeftEdge   = OffX + ComputeX( ng.ng_LeftEdge );
  169.         ng.ng_TopEdge    = OffY + ComputeY( ng.ng_TopEdge );
  170.         ng.ng_Width      = ComputeX( ng.ng_Width );
  171.         ng.ng_Height     = ComputeY( ng.ng_Height);
  172.  
  173.         SP_Main_Gadgets[ lc ] = g = CreateGadgetA((ULONG)SP_Main_GTypes[ lc ], g, &ng, ( struct TagItem * )&SP_Main_GTags[ tc ] );
  174.  
  175.         while( SP_Main_GTags[ tc ] ) tc += 2;
  176.         tc++;
  177.  
  178.         if ( NOT g )
  179.             return( 2L );
  180.     }
  181.  
  182.     if ( ! ( SP_Main_Wnd = OpenWindowTags( NULL,
  183.                 WA_Left,    wleft,
  184.                 WA_Top,        wtop,
  185.                 WA_Width,    ww + OffX + Scr->WBorRight,
  186.                 WA_Height,    wh + OffY + Scr->WBorBottom,
  187.                 WA_IDCMP,    BUTTONIDCMP|LISTVIEWIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
  188.                 WA_Flags,    WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH,
  189.                 WA_Gadgets,    SP_Main_GList,
  190.                 WA_Title,    SP_Main_Wdt,
  191.                 WA_ScreenTitle,    "SuperPlay Screen",
  192.                 TAG_DONE )))
  193.     return( 4L );
  194.  
  195.     GT_RefreshWindow( SP_Main_Wnd, NULL );
  196.  
  197.     return( 0L );
  198. }
  199.  
  200. void CloseSP_Main_Window( void )
  201. {
  202.     if ( SP_Main_Wnd        ) {
  203.         CloseWindow( SP_Main_Wnd );
  204.         SP_Main_Wnd = NULL;
  205.     }
  206.  
  207.     if ( SP_Main_GList      ) {
  208.         FreeGadgets( SP_Main_GList );
  209.         SP_Main_GList = NULL;
  210.     }
  211. }
  212.  
  213.